package com.example.design.proxy.cglib;

/*import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;*/

import java.lang.reflect.Method;

public class ProxyFactory /*implements MethodInterceptor*/ {
    private Object target;

    public ProxyFactory(Object target) {
        this.target = target;
    }

    /**
     * 返回代理对象
     * @return
     *//*
    public Object getProxyInstanct() {
        //创建一个工具类
        Enhancer enhancer = new Enhancer();
        //设置父类
        enhancer.setSuperclass(target.getClass());
        //设置回调函数
        enhancer.setCallback(this);
        //返回代理对象
        return enhancer.create();
    }

    *//**
     * 重写intercept方法，调用目标方法
     * @param o
     * @param method
     * @param args
     * @param methodProxy
     * @return
     * @throws Throwable
     *//*
    @Override
    public Object intercept(Object o, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println("Cglib代理模式开始前的方法.");
        Object invoke = method.invoke(target, args);
        System.out.println("Cglib代理模式结束后的方法");
        return invoke;
    }*/
}
